*****************************************************************************************************************************************************
* PROJECT: 		Exposure to the COVID-19 Stock Market Crash and its Effect on Household Expectations
* DATE: 		Nov 2020
* CONTENT: 		FIGURES
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"
		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/


*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** FIGURE A17 PANELS A & B
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~				

use data/processed/data_1, clear 	
* Scale USD variables	
	foreach x in  delofin_USD_tr02 delretir_USD_tr02  delfinwealth_USD_tr02   delhhnetinc_USD_tr02 ///
	delofin_USD_tr02alt delretir_USD_tr02alt  delfinwealth_USD_tr02alt	{
		replace `x' = `x'/1000
	}
	foreach x in ofinwealth_lvl retirewealth_lvl  finwealth_Jan20 hhinc_lvl hhnetinc_2019   {
		replace `x' = `x'/1000
	}
 replace del_retir_perc_tr02 = 0 if del_finwealth_perc_tr02!=. & del_ofin_perc_tr02!=. &del_retir_perc_tr02==.
 replace del_ofin_perc_tr02 = . if del_finwealth_perc_tr02==. & del_retir_perc_tr02==. &del_ofin_perc_tr02!=.
 replace del_ofin_perc_tr02 = . if del_finwealth_perc_tr02==. & del_retir_perc_tr02==.
 replace del_retir_perc_tr02 = . if del_finwealth_perc_tr02==. & del_ofin_perc_tr02==.
 replace del_ofin_perc_tr02 = 0 if del_finwealth_perc_tr02==. & del_ofin_perc_tr02==.
  

* CHANGE IN FINANCIAL WEALTH  
  
  * change in fin wealth by netwealth
	graph bar (mean)  del_ofin_perc_tr02 del_retir_perc_tr02  del_finwealth_perc_tr02 , ///
		over(netwealth_Jan20_grp, relabel(1 1 2 2 3 3 4 4 5 5)) b1title() ///
		bargap(0)  /// 
		ytitle("%", size(medsmall)) ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-20(5)0, nogrid)  legend(size(small) symxsize(3) symysize(3)  pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/temp1.gph, replace)
		
 * change in fin wealth by age	
	graph bar (mean)  del_ofin_perc_tr02 del_retir_perc_tr02  del_finwealth_perc_tr02 , ///
		over(agecat, relabel(1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+") label(labsize(small))) b1title() ///
		  bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-20(5)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/temp2.gph, replace)
	
* change in fin wealth by hh net income		
	graph bar (mean)  del_ofin_perc_tr02 del_retir_perc_tr02  del_finwealth_perc_tr02 , ///
		over(hhnetinc_2019_grp) b1title() ///
		  bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-20(5)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/temp3.gph, replace)

* CHANGE IN INCOME

  * change in hh income by netwealth	
	graph bar (mean) del_hhnetinc_perc_tr02 , ///
		over(netwealth_Jan20_grp, relabel(1 1 2 2 3 3 4 4 5 5)) b1title() ///
		bargap(0)  /// 
		ytitle("%", size(medsmall)) ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-8(2)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/temp4.gph, replace)
		
 * change in hh income by age		
	graph bar (mean)  del_hhnetinc_perc_tr02 , ///
		over(agecat, relabel(1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+") label(labsize(small))) b1title() ///
		 bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-8(2)0, nogrid)  saving(Figures/temp5.gph, replace)
		
 * change in hh income by hh net income		
	graph bar (mean) del_hhnetinc_perc_tr02 , ///
		over(hhnetinc_2019_grp) b1title() ///
		bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-8(2)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/temp6.gph, replace)
* USD
  * change in fin wealth by netwealth
	graph bar (mean) delofin_USD_tr02alt delretir_USD_tr02alt  delfinwealth_USD_tr02alt ,  ///
		over(netwealth_Jan20_grp, relabel(1 1 2 2 3 3 4 4 5 5))  b1title(Net wealth quintile, size(medsmall)) /// 
		  bargap(0)  /// 
		ytitle("$1000", size(medsmall)) ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-120(20)0, nogrid)  legend(size(small) symxsize(3) symysize(3)  pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/tempd1.gph, replace)

	*change in fin wealth by age
	graph bar (mean)  delofin_USD_tr02alt delretir_USD_tr02alt  delfinwealth_USD_tr02alt  , ///
		over(agecat, relabel(1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+") label(labsize(small))) b1title(Age group, size(medsmall)) ///
		bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-120(20)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/tempd2.gph, replace)
	
  * change in fin wealth by net income
	graph bar (mean) delofin_USD_tr02alt delretir_USD_tr02alt  delfinwealth_USD_tr02alt , ///
		over(hhnetinc_2019_grp) b1title(Net income quintile, size(medsmall)) ///
		  bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-120(20)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/tempd3.gph, replace)
	
  * change in hh income by netwealth	
	graph bar (mean) delhhnetinc_USD_tr02alt_qtr , ///
		over(netwealth_Jan20_grp, relabel(1 1 2 2 3 3 4 4 5 5)) b1title(Net wealth quintile, size(medsmall)) ///
		bargap(0)  /// 
		ytitle("$", size(medsmall)) ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-1250(250)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/tempd4.gph, replace)
			
 * change in hh income by age		
	graph bar (mean)  delhhnetinc_USD_tr02alt_qtr , ///
		over(agecat, relabel(1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+")label(labsize(small))) b1title(Age group, size(medsmall)) ///
		 bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-1250(250)0, nogrid)  saving(Figures/tempd5.gph, replace)
		
 * change in hh income by hh net income		
	graph bar (mean) delhhnetinc_USD_tr02alt_qtr , ///
		over(hhnetinc_2019_grp) b1title(Net income quintile, size(medsmall)) ///
		bargap(0)  /// 
		ytitle("") ///
		yline(0, lcolor(gs8) lpattern(dash)) graphregion(color(white)) bgcolor(white) ///
		ylabel(-1250(250)0, nogrid)  legend(size(small) pos(6) ring(1) cols(6) ///
		label(1 "Other financial wealth") label(2 "Retirement wealth") ///
		label(3 "Total financial wealth")) saving(Figures/tempd6.gph, replace)
	
		grc1leg2 		Figures/temp1.gph ///
						Figures/temp3.gph ///
						Figures/temp2.gph ///
						Figures/tempd1.gph ///
						Figures/tempd3.gph ///
						Figures/tempd2.gph ///
						, cols(3) rows(2) ysize(2) xsize(3) ///
						ring(1) pos(6) legendfrom(Figures/temp1.gph) ///
						l1title("Change in financial wealth", size(small)) ///
						saving(Figures/tempx.gph, replace) imargin(.1)
					
	graph export Figures/FigureA17A.pdf, as(pdf) replace				
	graph export Figures/FigureA17A.png, width(1600) replace						
				
		graph combine 	Figures/temp4.gph ///
						Figures/temp6.gph ///
						Figures/temp5.gph ///
						Figures/tempd4.gph ///
						Figures/tempd6.gph ///
						Figures/tempd5.gph 	, cols(3) rows(4) ysize(2) xsize(3) ///
						l1title("Change in household net income", size(small)) ///
						saving(Figures/tempy.gph, replace) 	imargin(1) xcommon 
		
	graph export Figures/FigureA17B.pdf, as(pdf) fontface("cmr10") replace			
	graph export Figures/FigureA17B.png, width(1600) replace		
	

forvalues x = 1/6 {
		capture erase Figures/temp`x'.gph
		capture erase Figures/tempd`x'.gph
}				
	capture erase Figures/tempx.gph
	capture erase Figures/tempy.gph
